package com.ysjr.testapp;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.ysjr.baseinterfacelib.BaseInterface;

/**
 * -----------------------------------
 * (☆^ー^☆)
 *
 * @author : Ani_aierJun
 * github: https://github.com/aierjun
 * email: aierjun@qq.com
 * create in : 13:55 2019/5/7
 * -----------------------------------
 */


public class BaseActivity extends Activity implements BaseInterface {

    protected Activity that;

    @Override
    public void attach(Activity context) {
        that = context;
    }

    @Override
    public void setContentView(View view) {
        if (that == null)
            super.setContentView(view);
        else
            that.setContentView(view);
    }

    @Override
    public <T extends View> T findViewById(int id) {
        if (that == null)
            return super.findViewById(id);
        else
            return that.findViewById(id);
    }

    @Override
    public ClassLoader getClassLoader() {
        if (that == null)
            return super.getClassLoader();
        else
            return that.getClassLoader();
    }

    @Override
    public LayoutInflater getLayoutInflater() {
        if (that == null)
            return super.getLayoutInflater();
        else
            return that.getLayoutInflater();
    }

    @Override
    public Window getWindow() {
        if (that == null)
            return super.getWindow();
        else
            return that.getWindow();
    }

    @Override
    public WindowManager getWindowManager() {
        if (that == null)
            return super.getWindowManager();
        else
            return that.getWindowManager();
    }

    @Override
    public Resources getResources() {
        if (that == null)
            return super.getResources();
        else
            return that.getResources();
    }

    @Override
    public void startActivity(Intent intent) {
        Intent newIntent = new Intent();
        newIntent.putExtra("className", intent.getComponent().getClassName());
        that.startActivity(newIntent);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {

    }

    @Override
    public void onStart() {

    }

    @Override
    public void onResume() {

    }

    @Override
    public void onPause() {

    }

    @Override
    public void onStop() {

    }

    @Override
    public void onRestart() {

    }

    @Override
    public void onDestroy() {

    }

    @Override
    public void onSaveInstanceState(Bundle savedInstanceState) {

    }

    @Override
    public void onBackPressed() {

    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return false;
    }
}
